﻿using System;
using System.Collections.Generic;
using System.Linq;
using VoteServices.VoteClass;

namespace VoteServices
{
    /// <summary>
    /// 问题服务
    /// </summary>
    public class ProblemService
    {
        /// <summary>
        /// 获取问题
        /// </summary>
        /// <returns>Problem List</returns>
        public List<Problem> GetProblems()
        {
            return VoteData.problems.ToList();

        }
        /// <summary>
        /// 获取选项
        /// </summary>
        /// <param name="ProblemId"></param>
        /// <returns>Option List</returns>
        public List<Option> GetOptions(int ProblemId)
        {
            return VoteData.options.Where(o => o.ProblemId == ProblemId).ToList();
        }
        /// <summary>
        /// 过期检测
        /// </summary>
        /// <param name="problem"></param>
        /// <returns></returns>
        public Boolean PastDue(Problem problem)
        {
            if (DateTime.Compare(problem.OverdueTime, DateTime.Now) > 0)
                return true ;
            else
                return false;
        }

    }
}
